﻿using ConfExpert.Forms.Base;
using DevExpress.Utils;
using DevTeam;

using System;
using System.Drawing;
using System.Windows.Forms;

namespace ConfExpert.Forms.Depo
{
    public partial class IDLEStok : XForm
    {
        public IDLEStok()
        {
            InitializeComponent();
        }

        BindingSource bs1, bs2;
        private void IDLEStok_Load(object sender, EventArgs e)
        {

            bs1 = gv1.Init("GetIdleStok");
            bs2 = gv1.AddDetailGrid(gv2, "CustomerId");

            gv1.FormatAsNumber(1, "IDLEQty", "ReservedQty", "TotalQty");
            gv2.FormatAsNumber(1, "IDLEQty", "ReservedQty", "TotalQty");

            gv1.AddSummary("IDLEQty", "ReservedQty", "TotalQty");
            gv2.AddSummary("IDLEQty", "ReservedQty", "TotalQty");

            gv2.Columns["CustomerId"].Visible = false;
            gv1.RowCellStyle += new DevExpress.XtraGrid.Views.Grid.RowCellStyleEventHandler(gv1_RowCellStyle);
            gv2.RowCellStyle += new DevExpress.XtraGrid.Views.Grid.RowCellStyleEventHandler(gv1_RowCellStyle);

            gv2.DoubleClick += new EventHandler(gv2_DoubleClick);

            splitContainerControl2.AutoSize();
            gv1.BestFitColumns();
            gv2.BestFitColumns();
        }

        void gv2_DoubleClick(object sender, EventArgs e)
        {
            using (IDLEStokRezerve r = new IDLEStokRezerve(intParse(bs1, "CustomerId"), intParse(bs2, "ProductId")))
            {
                r.ShowDialog();
            }
        }

        void gv1_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
        {
            switch (e.Column.FieldName)
            {
                case "CustomerId":
                case "PRO":
                    e.Appearance.Font = new Font(AppearanceObject.DefaultFont, FontStyle.Bold);
                    break;
                default:
                    break;
            }
        }

    }
}